"""
Project Name : api_automation_framework
File Name : bytes_n.py
Author : lldhsds
Date : 2024/12/28 13:45
Description: /bytes/{n}, 返回使用给定种子生成的n个随机字节。
"""

import requests

def bytes_n(n: int) -> None:
    """
    /bytes/{n}, GET, 返回使用给定种子生成的n个随机字节。
    :param n:
    :return: 200(Bytes)
    """
    url = f"http://httpbin.org/bytes/{n}"
    # Define the request header to accept binary data
    headers = {'accept': 'application/octet-stream'}
    response = requests.get(url, headers=headers)
    print(response.status_code)
    print(response.headers)

    # Print the binary content of the response
    print(response.content)
    # save the binary content to a file
    with open('./downloadfile', 'wb') as file:
        file.write(response.content)


bytes_n(10)
